package com.replication.jdbc;

import java.sql.SQLException;
import java.sql.Statement;

public class StatementOpts {
    String cursorName;
    Boolean escapeProcessing;
    Integer fetchDirection;
    Integer fetchSize;
    Integer maxFieldSize;
    Integer maxRows;
    Boolean poolable;
    Integer queryTimeout;

    public String getCursorName() {
        return cursorName;
    }

    public void setCursorName(String cursorName) {
        this.cursorName = cursorName;
    }

    public boolean isEscapeProcessing() {
        return escapeProcessing;
    }

    public void setEscapeProcessing(boolean escapeProcessing) {
        this.escapeProcessing = escapeProcessing;
    }

    public int getFetchDirection() {
        return fetchDirection;
    }

    public void setFetchDirection(int fetchDirection) {
        this.fetchDirection = fetchDirection;
    }

    public int getFetchSize() {
        return fetchSize;
    }

    public void setFetchSize(int fetchSize) {
        this.fetchSize = fetchSize;
    }

    public int getMaxFieldSize() {
        return maxFieldSize;
    }

    public void setMaxFieldSize(int maxFieldSize) {
        this.maxFieldSize = maxFieldSize;
    }

    public int getMaxRows() {
        return maxRows;
    }

    public void setMaxRows(int maxRows) {
        this.maxRows = maxRows;
    }

    public boolean isPoolable() {
        return poolable;
    }

    public void setPoolable(boolean poolable) {
        this.poolable = poolable;
    }

    public int getQueryTimeout() {
        return queryTimeout;
    }

    public void setQueryTimeout(int queryTimeout) {
        this.queryTimeout = queryTimeout;
    }

    public void bound(Statement stmt) throws SQLException {
        if (cursorName != null) {
            stmt.setCursorName(cursorName);
        }

        if (fetchDirection != null) {
            stmt.setFetchDirection(fetchDirection);
        }
        if (fetchSize != null) {
            stmt.setFetchSize(fetchSize);
        }
        if (maxFieldSize != null) {
            stmt.setMaxFieldSize(maxFieldSize);
        }
        if (maxRows != null) {
            stmt.setMaxRows(maxRows);
        }

        if (queryTimeout != null) {
            stmt.setQueryTimeout(queryTimeout);
        }

        if (escapeProcessing != null) {
            stmt.setEscapeProcessing(escapeProcessing);
        }

        if (poolable != null) {
            stmt.setPoolable(poolable);
        }
    }
}
